46

I'm using xampp portable server and I'm having some trouble with Apache http server, it says "ServerRoot must be a valid directory"

Command line output:

Please close this command only for Shutdown Apache 2 is starting ... httpd.exe: Syntax error on line 35 of K:/../../../xampp/apache/conf/httpd.conf: ServerRoot must be a valid directory Apache could not be started 

I checked the line 35 of xampp/apache/conf/httpd.conf and it was:

ServerRoot "/xampp/apache" 

Which doesn't exist. My folders are:

K:/../../../xampp/apache/conf <- where the httpd.conf is K:/../../../xampp/apache/ <- the server root K:/../../../xampp/apache/modules <- where server modules are 

If i change (at line 35) to

ServerRoot ".." 

It says:

Please close this command only for Shutdown Apache 2 is starting ... httpd.exe: Syntax error on line 65 of K:/../../../xampp/apache/conf/httpd.conf: Cannot load modules/mod_access_compat.so into server: Unable to find the specified module Apache could not be started 

I checked, and modules/mod_access_compat.so exists, so i can't figure out how to fix it.

Any help will be appreciated

14 Answers 14

94

Just run setup_xampp.bat from shell (shell from XAMPP control panel)and the paths should be set automatically for the portable version of XAMPP for windows. It has worked for me.

Sign up to request clarification or add additional context in comments.

8 Comments

"It says sorry but nothing to do"
Working all... setup_xampp.bat its batch file will config with all paths in xampp...
this is especially useful when you install xampp in a custom dir (not c:/xampp ...)
where is that setup_xampp.bat? i am facing same issue here
In the worst case, change the Listen 80 to Listen 90 in httpd.conf. This solution is just to create a development environment @ local machine not on live server. Restart Xampp and access the site @ port 90 .
|
29

navigate to httpd.conf file in conf direcotry in Apache24 or whatever apache file you have.

Go to ServerRoot= ".." line and change the value to the path where apache is located like "C:\Program Files\Apache24"

2 Comments

I thought you're not supposed to install XAMPP in program files due to permissions issues in Windows?
Also if you're directory is something like a 'd:\Apache24', dont forget to make changes at all places in httpd.conf. There are many changes where it refers to c:\Apache24 by default.
5

Change below path in httpd.conf file to your setup. This will fix the issue.

Define SRVROOT "C:\Apache24" ServerRoot "${SRVROOT}" 

Comments

4

If you open an editor and jump to the exact line shown in the error message (within the file httpd.conf), this is what you'd see:

#LoadModule access_compat_module modules/mod_access_compat.so LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule allowmethods_module modules/mod_allowmethods.so LoadModule asis_module modules/mod_asis.so LoadModule auth_basic_module modules/mod_auth_basic.so #LoadModule auth_digest_module modules/mod_auth_digest.so #LoadModule auth_form_module modules/mod_auth_form.so 

The paths to the modules, e.g. modules/mod_actions.so, are all stated relatively, and they are relative to the value set by ServerRoot. ServerRoot is defined at the top of httpd.conf (ctrl-F for ServerRoot ").

ServerRoot is usually set absolutely, which would be K:/../../../xampp/apache/ in your post.

But it can also be set relatively, relative to the working directory (cf.). If the working directory is the Apache bin folder, then use this line in your httpd.conf:

ServerRoot ../ 

If the working directory is the Apache folder, then this would suffice:

ServerRoot . 

If the working directory is the C: folder (one folder above the Apache folder), then use this:

ServerRoot Apache 

For apache services, the working directory would be C:\Windows\System32, so use this:

ServerRoot ../../Apache 

Comments

2

Make sure your ServerRoot in httpd.conf points correctly to the Apache path. Otherwise you will see this message for every further module.

Examples:

  • /etc/apache2/apache2 for Linux
  • "C:\Program Files\Apache24" for Windows

1 Comment

Please add an example path.
1

I would think that ServerRoot needs to be absolute. Use something like "/apache/docroot"

2 Comments

..that's not absolute though?
That is relative root.
1

If you use an actuall version there is a "setup_xampp.bat/.sh" script in the root directory. The path has to be absolute but the script changes all needed paths to your current location.

Comments

1

Use the drive letter with forward slashes to get started (c:/apache/...).

Comments

1
  1. Navigate to your XAMPP directory, you will find a folder called apache, open it, then copy its path, my path is "D:\Hacking Tools 2\Programs\XAMPP V2\apache"
  2. Open up apache\conf\httpd.conf with any text editor
  3. Scroll down until line 30-40
  4. You will find a code like this: ServerRoot "xampp\apache"
  5. Now, change it to be the apache directory, as I said in Step #1, my path is "D:\Hacking Tools 2\Programs\XAMPP V2\apache", so, my code will be ServerRoot "D:\Hacking Tools 2\Programs\XAMPP V2\apache"
  6. It should look somehow like this: ServerRoot "D:\XAMPP\apache"
  7. Now go back to the XAMPP main directory and run xampp_start.exe

It worked for me, if it doesn't work for you, just comment with the error value after opening the xampp_start.exe

Comments

1

Run "setup_xampp.bat/.sh" and then Delete "\" at the end, so your ServerRoot should be like "C:.....\apache" NO "C:.....\apache\"

Comments

1

Below solved. I have wrongly given the bin /directory/, so faced the issue:

if you installed apache at C:/httpd-2.4.41-o102s-x64-vc14-r2/Apache24
then the modules are at.. C:/httpd-2.4.41-o102s-x64-vc14-r2/Apache24/modules

So, the file C:/httpd-2.4.41-o102s-x64-vc14-r2/Apache24/conf/httpd.conf should have Define SRVROOT "C:/httpd-2.4.41-o102s-x64-vc14-r2/Apache24/" 

Hope that helps

Comments

1

That for changing directory of the XAMPP. So you have to change the Directory as well as ServerRoot "E:/xampp/apache"

DocumentRoot "E:/xampp/htdocs" <Directory "E:/xampp/htdocs"> ScriptAlias /cgi-bin/ "E:/xampp/cgi-bin/" <Directory "E:/xampp/cgi-bin"> AllowOverride All Options None Require all granted </Directory> 

I also facing same problem for changing My laptop. thanks

Comments

0

I checked the line 35 of xampp/apache/conf/httpd.conf and it was:

ServerRoot "/xampp/apache"

Which doesn't exist. ...

Create the directory, or change the path to the directory that contains your hypertext documents.

Comments

0

I had this exact same problem with Xampp portable on Windows 10 Home. I went through all the suggestions and none worked. I did get it working with Windows Firewall Settings and an error on my part.

My pen drive was labelled Drive E on my laptop and Drive F on my Desktop. Once I corrected that using disk partition and changed the drive letter to E for my desktop to windows asked for access for the firewall and everything clicked.

The steps to correct the drive letter were: 1. Hit the windows key and type Partition, "create and format harddisks partitions" should be at the top, hit enter 2. Find the drive you are looking for at the top panel and click on it. 3. Right click on it and select change drive letter and path, click okay 4. Now try to start xampp control panel and start Apache and Mysql 5. if you get the windows firewall click allow.

I can't say this will work but it did for me and is what I added to this discussion. I also think it might have been just the firewall did not allow the oither drive letter.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.